Public Class frmSEARCH_CUSTOMER
    Dim Condition As Integer = 2
    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Dim frm As New frmCUSTOMER_DETAIL
        frm.ShowDialog()
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub GridCustomer_ColumnHeaderClick(ByVal sender As System.Object, ByVal e As Janus.Windows.GridEX.ColumnActionEventArgs) Handles GridCustomer.ColumnHeaderClick
        Select Case e.Column.Key
            Case "CUS_CODE"
                Condition = 1
            Case "CUS_NAME"
                Condition = 2
            Case "ADDRESS"
                Condition = 4
            Case "PHONE"
                Condition = 3
            Case "CARD_NUMBER"
                Condition = 5
        End Select
        Search()
    End Sub
    Private Sub Search()
        If txtParameter.Text <> "" Then
            Dim arName As New ArrayList
            arName.Add("@Condition")
            arName.Add("@Parameter")
            Dim arVal As New ArrayList
            arVal.Add(Condition)
            arVal.Add(txtParameter.Text)
            Dim dt As DataTable = BLL.ObjectGetBy("CUSTOMER_SEARCH", arName, arVal)
            GridCustomer.DataSource = dt.DefaultView
        End If
    End Sub
    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        
    End Sub

    Private Sub Keyboardcontrol1_UserKeyPressed(ByVal sender As System.Object, ByVal e As VINAPOS.KeyboardClassLibrarySmall.KeyboardEventArgs) Handles Keyboardcontrol1.UserKeyPressed
        txtParameter.Focus()
        SendKeys.Send(e.KeyboardKeyPressed)

    End Sub

    Private Sub frmSEARCH_CUSTOMER_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        'Try
        '    GC.Collect()
        '    Me.Dispose()
        'Catch ex As Exception

        'End Try
    End Sub

    Private Sub frmSEARCH_CUSTOMER_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)
    End Sub

    Private Sub btnDetail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDetail.Click
        If GridCustomer.RowCount > 0 Then
            Dim dr As DataRowView = CType(GridCustomer.CurrentRow.DataRow, DataRowView)
            Dim frm As New frmCUSTOMER_DETAIL
            frm.dr_customer = dr
            frm.ShowDialog()
        End If
        
    End Sub

    Private Sub txtParameter_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtParameter.TextChanged
        Search()
    End Sub
End Class